package com.mxpio.erp.common.equipment.service;

import com.mxpio.erp.common.enums.EquipmentEnums;
import com.mxpio.erp.common.equipment.entity.EquipmentUpkeepTask;
import com.mxpio.erp.common.equipment.entity.EquipmentUpkeepTaskEvaluate;
import com.mxpio.erp.common.equipment.entity.EquipmentUpkeepTaskPickupLine;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import com.mxpioframework.common.exception.MBootException;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import com.mxpioframework.system.service.BaseService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;


/**
 * 保养任务Service接口
 *
 * @author Cheng
 * @date 2023-07-28
 */
public interface EquipmentUpkeepTaskService extends BaseService<EquipmentUpkeepTask> {

    Page<EquipmentUpkeepTask> taskPage(String flag, Pageable page, Criteria c);

    /**
     * 查询维修中的列表
     * @return
     */
    List<EquipmentUpkeepTask> queryExecutingList();

    void saveTask(EquipmentUpkeepTask upkeepTask);

    void updateTask(EquipmentUpkeepTask upkeepTask);

    /**
     * 下达任务
     * @param id 执行人
     */
    void release(String id);

    /**
     * 派工
     * @param id 工单id
     * @param executor 执行人
     */
    void dispatch(String id, String executor) throws MBootException;

    /**
     * 抢单
     * @param id 工单id
     * @throws MBootException
     */
    void grab(String id)throws MBootException;

    /**
     * 执行任务
     * @param equipmentUpkeepTask
     */
    void excut(EquipmentUpkeepTask equipmentUpkeepTask)throws MBootException;

    /**
     * 开始执行
     * @param id
     */
    void startExcut(String id)throws MBootException;


    /**
     * 暂停
     * @param reason
     * @param id
     */
    void stopUpkeepById(String reason, String id);

    /**
     * 暂停结束
     * @param id
     */
    void endStop(String id);

    /**
     * 转单
     * @param id 工单id
     * @param executor 新执行人
     * @param reason 原因
     */
    void reSend(String id, String executor,String reason)throws MBootException;
    /**
     * 签核驳回
     * @param id
     */
    void signOffBack(String id,String reason);

    Result<?> change(EquipmentUpkeepTask task);

    Result<?> veto(EquipmentUpkeepTask task);

    Result<?> submit(EquipmentUpkeepTask task);

    Result<?> check(EquipmentUpkeepTask task);

    Result<?> evaluate(List<EquipmentUpkeepTaskEvaluate> evaluates);


    Result<List<EquipmentUpkeepTaskPickupLine>> executePickUp(EquipmentUpkeepTask order, List<OrderExcuteLineVo> lines);

    Result<Object> executeReturn(EquipmentUpkeepTask order, List<OrderExcuteLineVo> lines);

    Result<String> deleteWithSub(List<String> bizNoList);

    Result<?> shut(EquipmentUpkeepTask task);

    Result<EquipmentUpkeepTask> updateOccupy(EquipmentUpkeepTask byId) throws Exception;

    Result<EquipmentUpkeepTask>  updateTime(EquipmentUpkeepTask equipmentUpkeepTask, EquipmentEnums.PmisHode productionscheduled);

    /**
     * 当前登录用户协助的工单信息
     * @param criteria
     * @param page
     * @return
     */
    Page<EquipmentUpkeepTask> userAssistedTickets(Criteria criteria, Pageable page);

    void adminUpdateTask(EquipmentUpkeepTask equipmentUpkeepTask);
}
